<template>
	<view class="content mainpadding">
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./revisePassword')">
			<view class="color_ling text_g">修改密碼</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./revisePhone')">
			<view class="color_ling text_g">更換手機號</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./setpassword')">
			<view class="color_ling text_g">設置支付密碼</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./takeAddress')">
			<view class="color_ling text_g">收貨地址</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./feedback')">
			<view class="color_ling text_g">意見反饋</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./aboutUs')">
			<view class="color_ling text_g">關於我們</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./privacyAgreement')">
			<view class="color_ling text_g">隱私政策</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./userAgreement')">
			<view class="color_ling text_g">用戶協議</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="goDelivery">
			<view class="color_ling text_g">實名認證</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="paddingtb line_b9 flexbetween" @click="jumpUrl('./help')">
			<view class="color_ling text_g">幫助中心</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<!-- <view class="mainpadding flexbetween" @click="jumpurl('/pages/caozuoshouce/shiyongsc?type=2')">
			<view class="main_size hei_text">使用操作手冊</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view> -->
		<view class="paddingtb line_b9 flexbetween" @click="shows=true">
			<view class="color_ling text_g">清除緩存</view>
			<view class="color_ling text_g">{{fileSizeString}}</view>
		</view>
		<view class="paddingtb line_b9 flexbetween">
			<view class="color_ling text_g">版本號</view>
			<view class="color_ling text_g">1.1.6</view>
		</view>
		<view class="footer">
			<view class="footerButton" @click="show=true">
				退出登錄
			</view>
		</view>
		<!-- <u-modal :show="show" showCancelButton title="退出登錄" content='您確定要退出登錄吗？'></u-modal> -->
		<u-modal :show="show" showCancelButton confirmColor="#FFB800" @cancel="show=false" @confirm="outLogin"
			confirmText="確認" cancelText="取消">
			<view class="slot-content color_ling text_weight text">
				您確定要退出登錄吗？
			</view>
		</u-modal>
		<u-modal :show="shows" showCancelButton confirmColor="#FFB800" @cancel="shows=false" @confirm="confirm"
			confirmText="確認" cancelText="取消">
			<view class="slot-content color_ling text_weight text">
				您確定要清除緩存吗？
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				shows: false,
				show: false,
				status: 0, //0未提交實名認證審核 1已提交實名認證審核
				fileSizeString: "",
			}
		},
		onLoad() {
			this.getTakeInfo()
			this.formatSize()
		},
		methods: {
			formatSize() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						let size = res.currentSize;
						if (size < 1024) {
							that.fileSizeString = size + ' B';
						} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
							that.fileSizeString = Math.floor(size / 1024 * 100) / 100 + ' KB';
						} else if (size / 1024 / 1024 >= 1) {
							that.fileSizeString = Math.floor(size / 1024 / 1024 * 100) / 100 + ' M';
						}
					}
				})
			},
			// 清楚緩存
			clearCache() {
				let that = this;
				uni.clearStorageSync();
				//重新獲取并显示清除後的緩存大小
				httpRequest.toast("清除緩存成功，系統已爲您自動退出登錄")
				setTimeout(() => {
					uni.navigateBack(1)
				}, 1000)
			},
			confirm() {
				this.shows = false;
				this.clearCache()
			},
			async getTakeInfo() { //獲取實名認證信息
				let _this = this
				let res = await this.http.request('/api/member/Idendeail', 'GET', {})
				if (res.code == 1) {
					this.status = 1
				} else if (res.code == 0) {
					this.status = 0
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			goDelivery() {
				if (this.status == 0) {
					uni.navigateTo({
						url: "/pages_mine/realAuthentication"
					})
				} else {
					uni.navigateTo({
						url: "/pages_mine/realAuthenticationExamine"
					})
				}
			},
			jumpUrl(url) {
				uni.navigateTo({
					url: url
				})
			},
			outLogin() { //退出登錄
				this.show = false
				uni.removeStorageSync('token');
				uni.removeStorageSync('user_id');
				uni.removeStorageSync('client_id');
				this.http.toast("退出登錄成功！")
				setTimeout(() => {
					uni.navigateBack(1)
				}, 500)
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>